//
// Created by 11067 on 2023/3/6.
//

#ifndef WORD_LIST_CORE_OPTIONPARSER_H
#define WORD_LIST_CORE_OPTIONPARSER_H

#include <string>
#include <utility>
#include <cstring>

/**
 * 要计算的目标
 */
enum class CountType{
    NotSpecified,
    WordChainCount, // 计算单词文本中可以构成多少个单词链
    MaxWordLengthWordChain, // 计算最多单词数量的单词链
    MaxAlphabetLengthWordChain, // 计算字母最多的单词链
};



struct Options{
    CountType countType;
    char beginWith; // ‘\0'如果未指定,下同
    char endWith;
    char notBeginWith;
    bool isCycleAllowed;
    const char *filename;

    bool operator==(const Options &rhs) const {
        // why should I fully cover all branches of this plain
        // Eq operator???
        // use bitwise-or to work around.
        return countType == rhs.countType &
               beginWith == rhs.beginWith &
               endWith == rhs.endWith &
               notBeginWith == rhs.notBeginWith &
               isCycleAllowed == rhs.isCycleAllowed &
                strcmp(filename, rhs.filename) == 0;
    }

    bool operator!=(const Options &rhs) const {
        return !(rhs == *this);
    }



};
class OptionParser{
public:
    /**
     * 处理命令行参数
     * @param argc main函数传入的参数
     * @param argv main函数传入的参数
     * @param options 选项
     * @return
     */
    static int parse(int argc, char* argv[], Options& options);
};
#endif //WORD_LIST_CORE_OPTIONPARSER_H
